"""
Description: create a new list df, each key item will be repeatedly saved into list  in according to the item value.
"""

import numpy as np
import random
Respo = {'袜子':10,'鞋子':20, '拖鞋':30, '项链':40}

#creat a new list
df = []

# Each key item will be repeatedly saved into list  in according to the item value.
for keys, values in Respo.items():
  for i in range(0, values):
    df.append(keys)
random.shuffle(df)

#Print 20 times in order to check the possibility of each item's occurrence
for j in range(0,20):
  i = random.randint(0,len(df)-1)
  print(df[i])


# 思路是对的，但是没有把整个思路完整地整理出来。老师写了一段测试代码，你可以参考一下，将结果写成函数
temp = {}
for j in range(0,100000):
    i = random.randint(0,len(df)-1)
#     print(df[i])
    if temp.get(df[i]) is None:
        temp[df[i]] = 1
    else:
        temp[df[i]] += 1
print(temp)